
using SimpleTicketBooking.Middlewares;
using SimpleTicketBooking.Service;
using SimpleTicketBooking.Service.Impl;
using SimpleTicketBooking.Utils.Ext;
using SimpleTicketBooking.Utils.Filters;

namespace SimpleTicketBooking
{
    /// <summary>
    /// app start up class
    /// </summary>
    public class Program
    {
        /// <summary>
        /// start up main class
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);

            // Add services to the container.

            builder.Services.AddControllers(options => {
                options.Filters.Add<ResultWrapperFilter>();
            });

            // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
            builder.Services.AddEndpointsApiExplorer();
            builder.Services.AddSwaggerExt();

            // Version control setting
            builder.Services.AddApiVersioning(options => options.ReportApiVersions = true).AddMvc();

            builder.Services.AddTransient<IJWT, SimpleJWT>();

            var app = builder.Build();

            // Configure the HTTP request pipeline.
            if (app.Environment.IsDevelopment())
            {
                app.UseSwaggerExt();
            }

            app.UseHttpsRedirection();

            app.UseAuthorization();

            app.UseJwt();

            app.UseException();

            app.MapControllers();

            app.Run();
        }
    }
}
